<?php
	//get value from submit form
	$cm=$_POST['comment'];
	
	//include class for mail
	include_once ('class.phpmailer.php');
    $mail = new PHPMailer(true);
	//telling the class to use SMTP
	$mail->IsSMTP();
	try {
		// SMTP server
		$mail->Host = "mail.hrcambodia.com";
		// enables SMTP debug information (for testing),  show debug : SMTPDebug  = 2,  Hide debug : SMTPDebug  = 1
		$mail->SMTPDebug = 1;
		// enable SMTP authentication
		$mail->SMTPAuth = true;
		// sets the SMTP server		
		$mail->Host = "mail.hrcambodia.com";
		// set the SMTP port for the MY OWN DOMAIN server
		$mail->Port = 25;
		// SMTP account username		
		$mail->Username = "support@hrcambodia.com";
		// SMTP account password
        $mail->Password = "t$=hI5M+CKqI";
			
        $mail->AddReplyTo('mail@hrcambodia.com', 'hrcambodia.com');
		//$mail->AddAddress('sovannrupp@gmail.com', 'Customer Feedback');
			
       	$email_address = filter_input(INPUT_GET, $_POST['comment'], FILTER_VALIDATE_EMAIL);
        if (!$email_address) {
			$mail->SetFrom('mail@hrcambodia.com', 'hrcambodia.com');
			$mail->AddAddress('sovannrupp@gmail.com', 'Sovann');
			//$mail->AddAddress('cyudeth29@gmail.com', 'Yudeth');
			//$mail->AddAddress('sovannrupp@gmail.com', 'Sovann');
                
            $mail->Subject = 'Customer Feedback';
            $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
            $mail->MsgHTML("This is an auto-generated copy of feedback that has been sent at HRCambodia.com website.<BR>Please allow a minimum of 24 hours for a reply below is the content of your feedback:<BR>Comment: <BR><BIG>".$cm."</BIG><BR><HR>HRCambodia.com Team<BR>Email: <BIG>info@hrcambodia.com</BIG>Website: <BIG>www.hrcambodia.com</BIG></p>");
            $mail->Send();
            //echo "Your message have been send. Thank you...!";
			header("Location: ../feedback.php");
		}else {
                echo 'Email is invalid...';
                break;
        }
	}catch(phpmailerException $e){
            //Pretty error messages from PHPMailer
            echo $e->errorMessage();
	}catch(Exception $e){
            //Boring error messages from anything else!
            echo $e->getMessage();
	}
		
?>